package com.aw.guiguzi.module.setting

import android.annotation.SuppressLint
import android.widget.LinearLayout
import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.Switch
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.aw.baselib.base.AwBaseBindingActivity
import com.aw.baselib.base.AwBaseEvent
import com.aw.baselib.constants.Extras
import com.aw.baselib.util.AwRecyclerViewUtil
import com.aw.guiguzi.R
import com.aw.guiguzi.bean.CalSuggestItemBean
import com.aw.guiguzi.constants.MyConstant
import com.aw.guiguzi.databinding.ActivitySettingUiBinding
import com.aw.guiguzi.event.EventRefreshAnalysisLengthType
import com.aw.guiguzi.event.EventRefreshAnalysisScreenOutPreLengthType
import com.aw.guiguzi.event.EventRefreshCalDifferenceLengthType
import com.aw.guiguzi.event.EventRefreshCalResultType
import com.aw.guiguzi.event.EventRefreshLimitStatisticsCountLengthType
import com.aw.guiguzi.listeners.OnCommonCheckedListener
import com.aw.guiguzi.listeners.OnCommonClickListener
import com.aw.guiguzi.module.setting.adapter.SettingUiSuggestAdapter
import com.aw.guiguzi.util.AppCacheUtil
import com.aw.guiguzi.util.AppUserUtil.isAdmin
import com.aw.guiguzi.util.CommonUtil.isAllow
import com.aw.guiguzi.util.CommonUtil.setOnCheckedChangeListener
import com.aw.guiguzi.util.CommonUtil.setOnCheckedChangeListenerNoAuth
import com.aw.guiguzi.util.CommonUtil.setOnClickListener
import com.aw.guiguzi.util.CommonUtil.setOnClickListenerNoAuth
import com.aw.guiguzi.util.DataUtil.allTrendList
import com.aw.guiguzi.util.DataUtil.matcherSearchText

class SettingUiActivity : AwBaseBindingActivity<ActivitySettingUiBinding?>() {
    
    private var mAdapter: SettingUiSuggestAdapter? = null
    private var mSuggestItemBeanList: MutableList<CalSuggestItemBean> = ArrayList()
    override fun refreshByBus(type: AwBaseEvent) {
        super.refreshByBus(type)
        if (type is EventRefreshAnalysisScreenOutPreLengthType) {
            setText(
                binding?.tvNumsScreenOutPreCustom,
                AppCacheUtil.getAnalysisNumsScreenOutPreCustom().toString()
            )
        } else if (type is EventRefreshAnalysisLengthType) {
            setText(binding?.tvLimit1, AppCacheUtil.getAnalysisLengthCustom().toString())
        } else if (type is EventRefreshLimitStatisticsCountLengthType) {
            setText(binding?.tvLimit2, AppCacheUtil.getLimitStatisticsCountCustom().toString())
        } else if (type is EventRefreshCalDifferenceLengthType) {
            val tag = type.getObj() as Int
            when (tag) {
                MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_ALL -> setText(
                    binding?.tvCalLengthDifferenceAll,
                    AppCacheUtil.getCalLengthDifferenceAll().toString()
                )

                MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_PRE15 -> setText(
                    binding?.tvCalLengthDifferencePre15,
                    AppCacheUtil.getCalLengthDifferencePre15().toString()
                )

                MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_LIMIT_ANALAYSIS -> setText(
                    binding?.tvCalLengthDifferenceLimitAnalaysis,
                    AppCacheUtil.getCalLengthDifferenceLimitAnalaysis().toString()
                )

                MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_LIMIT_STATISTICS -> setText(
                    binding?.tvCalLengthDifferenceLimitStatistics,
                    AppCacheUtil.getCalLengthDifferenceLimitStatistics().toString()
                )

                MyConstant.TYPE_EDIT_CAL_END_LENGTH -> setText(
                    binding?.tvCalEndLength,
                    AppCacheUtil.getCalEndLength().toString()
                )

                MyConstant.TYPE_EDIT_BETTER_TRENDS_PERCENT -> setText(
                    binding?.tvBetterTrendsPercent,
                    AppCacheUtil.getBetterTrendsPercent().toString() + "%"
                )
            }
        }
    }

    override fun getViewBinding(): ActivitySettingUiBinding {
        return ActivitySettingUiBinding.inflate(layoutInflater)
    }

    override fun initView() {
        super.initView()
        setToolbar("界面设置", null)
    }

    override fun initData() {
        super.initData()
        mAdapter = SettingUiSuggestAdapter()
        AwRecyclerViewUtil.setRecyclerViewLinearlayout(mActivity, binding?.rcvData, mAdapter, false)
        mSuggestItemBeanList = allTrendList
        mAdapter!!.addAllData(mSuggestItemBeanList)
        binding?.switchBettingCalArea?.isChecked = AppCacheUtil.isShowBettingCalArea()
        //        switch_handleInput.setChecked(AppCacheUtil.isHandleInputBetting());
        binding?.switchHandleInput?.isChecked = false
        binding?.switchHandleInput?.isEnabled = false
        binding?.switchMax!!.isChecked = AppCacheUtil.isStatisticsCountMax()
        binding?.switchAnalysisQuick!!.isChecked = AppCacheUtil.isAnalysisQuick()
        binding?.switchTypeStatisticsCount!!.isChecked = AppCacheUtil.isStatisticsCount()
        binding?.switchJumpSmoothly!!.isChecked = AppCacheUtil.isJumpSmoothly()
        binding?.switchCommonAnalysis!!.isChecked = AppCacheUtil.isCommonAnalysis()
        binding?.switchCombinationAnalysis!!.isChecked = AppCacheUtil.isCombinationAnalysis()
        binding?.switchTrendsAutoFilter!!.isChecked = AppCacheUtil.isTrendsAutoFilter()
        binding?.switchCommonSuggest!!.isChecked = AppCacheUtil.isCommonSuggest()
        binding?.switchBettingImitate!!.isChecked = AppCacheUtil.isShowBettingImitate()
        binding?.switchNumsScreenOutPre!!.isChecked = AppCacheUtil.isNumsScreenOutPre()
        binding?.switchColdAndHotDefault!!.isChecked = AppCacheUtil.isColdAndHotDefault()
        binding?.switchColdAndHotCustom!!.isChecked = AppCacheUtil.isColdAndHotCustom()
        binding?.switchHotShowModelDetail!!.isChecked = AppCacheUtil.isHotShowModelDetail()
        binding?.switchBetterTrendsPercent!!.isChecked = AppCacheUtil.isUseBetterTrendsPercent()
        binding?.switchTypePercent!!.isChecked = AppCacheUtil.isUseTypePercent()
        //        showView(binding?.rcvData, binding?.switchJumpSmoothly.isChecked());
        setText(
            binding?.tvNumsScreenOutPreCustom,
            AppCacheUtil.getAnalysisNumsScreenOutPreCustom().toString()
        )
        setText(binding?.tvCalLengthDifferenceAll, AppCacheUtil.getCalLengthDifferenceAll().toString())
        setText(binding?.tvCalLengthDifferencePre15, AppCacheUtil.getCalLengthDifferencePre15().toString())
        setText(
            binding?.tvCalLengthDifferenceLimitAnalaysis,
            AppCacheUtil.getCalLengthDifferenceLimitAnalaysis().toString()
        )
        setText(
            binding?.tvCalLengthDifferenceLimitStatistics,
            AppCacheUtil.getCalLengthDifferenceLimitStatistics().toString()
        )
        setText(binding?.tvCalEndLength, AppCacheUtil.getCalEndLength().toString())
        setText(binding?.tvBetterTrendsPercent, AppCacheUtil.getBetterTrendsPercent().toString() + "%")
        binding?.tvHintLimitCount!!.text = matcherSearchText(
            resources.getColor(com.aw.baselib.R.color.red),
            getString(R.string.hint_setting_ui_limit_count),
            getString(R.string.hint_setting_ui_modify),
            true
        )
        binding?.tvHintCalLengthDifference!!.text = matcherSearchText(
            resources.getColor(com.aw.baselib.R.color.red),
            getString(R.string.hint_setting_ui_cal_length_difference),
            getString(R.string.hint_setting_ui_modify),
            true
        )
        binding?.tvHintCalBetterTrendsPercentDifference!!.text = matcherSearchText(
            resources.getColor(com.aw.baselib.R.color.red),
            getString(R.string.hint_setting_ui_cal_better_trends_difference_percent),
            getString(R.string.hint_setting_ui_cal_better_trends_difference_percent2),
            true
        )
        binding?.rBtnAnalaysisModel1!!.isChecked = !AppCacheUtil.isAnalaysisModel2()
        binding?.rBtnAnalaysisModel2!!.isChecked = AppCacheUtil.isAnalaysisModel2()
        if (AppCacheUtil.getLimitType() == MyConstant.SWITCH_ALL) {
            binding?.rBtnLimitAll!!.isChecked = true
        } else if (AppCacheUtil.getLimitType() == MyConstant.SWITCH_LIMIT1) {
            binding?.rBtnLimit1!!.isChecked = true
        } else if (AppCacheUtil.getLimitType() == MyConstant.SWITCH_LIMIT2) {
            binding?.rBtnLimit2!!.isChecked = true
        }
        if (AppCacheUtil.getCalIntervalNum() == 1) {
            binding?.rBtnCalInterval1!!.isChecked = true
        } else if (AppCacheUtil.getCalIntervalNum() == 2) {
            binding?.rBtnCalInterval2!!.isChecked = true
        } else {
            binding?.rBtnCalInterval3!!.isChecked = true
        }
        setText(binding?.rBtnLimit1, "后" + AppCacheUtil.getAnalysisLengthCustom() + "位")
        setText(binding?.rBtnLimit2, "后" + AppCacheUtil.getLimitStatisticsCountCustom() + "位")
        setText(binding?.tvLimit1, AppCacheUtil.getAnalysisLengthCustom().toString())
        setText(binding?.tvLimit2, AppCacheUtil.getLimitStatisticsCountCustom().toString())
        showView(findViewById(R.id.tv_setHint), !isAdmin)
        if (!isAdmin) {
            binding?.rBtnAnalaysisModel1!!.isEnabled = false
            binding?.rBtnAnalaysisModel2!!.isEnabled = false
            binding?.rBtnCalInterval1!!.isEnabled = false
            binding?.rBtnCalInterval2!!.isEnabled = false
            binding?.rBtnCalInterval3!!.isEnabled = false
            binding?.rBtnLimit1!!.isEnabled = false
            binding?.rBtnLimit2!!.isEnabled = false
            binding?.rBtnLimitAll!!.isEnabled = false

//            switch_bettingCalArea.setEnabled(false);
            binding?.switchHandleInput?.isEnabled = false
            binding?.switchTypeStatisticsCount!!.isEnabled = false
            binding?.switchJumpSmoothly!!.isEnabled = false
            binding?.switchMax!!.isEnabled = false
            //            binding?.switchAnalysisQuick.setEnabled(false);
            binding?.switchCommonAnalysis!!.isEnabled = false
            binding?.switchCombinationAnalysis!!.isEnabled = false
            binding?.switchTrendsAutoFilter!!.isEnabled = false
            binding?.switchCommonSuggest!!.isEnabled = false
            //            binding?.switchBettingImitate.setEnabled(false);
            binding?.switchNumsScreenOutPre!!.isEnabled = false
            binding?.switchColdAndHotDefault!!.isEnabled = false
            binding?.switchColdAndHotCustom!!.isEnabled = false
            binding?.switchHotShowModelDetail!!.isEnabled = false
            binding?.switchBetterTrendsPercent!!.isEnabled = false
            binding?.switchTypePercent!!.isEnabled = false
            binding?.llNumsScreenOutPreCustom!!.isEnabled = false
            binding?.llCalLengthDifferenceAll!!.isEnabled = false
            binding?.llCalLengthDifferencePre15!!.isEnabled = false
            binding?.llCalLengthDifferenceLimitAnalaysis!!.isEnabled = false
            binding?.llCalLengthDifferenceLimitStatistics!!.isEnabled = false
            binding?.llCalEndLength!!.isEnabled = false
            binding?.llLimit1!!.isEnabled = false
            binding?.llLimit2!!.isEnabled = false
            binding?.tvCalLengthDifferenceAll!!.isEnabled = false
            binding?.tvCalLengthDifferencePre15!!.isEnabled = false
            binding?.tvCalLengthDifferenceLimitAnalaysis!!.isEnabled = false
            binding?.tvCalLengthDifferenceLimitStatistics!!.isEnabled = false
            binding?.tvCalEndLength!!.isEnabled = false
            binding?.tvHintLimitCount!!.isEnabled = false
            binding?.tvLimit1!!.isEnabled = false
            binding?.tvLimit2!!.isEnabled = false
        }
    }

    @SuppressLint("NonConstantResourceId")
    override fun initListener() {
        super.initListener()
        setOnClickListenerNoAuth(binding?.llNumsScreenOutPreCustom!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_ANALYSIS_SCREEN_OUT_PRE_NUMS_LENGTH
                )
            }

        })
        setOnClickListenerNoAuth(binding?.llLimit1!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_ANALYSIS_NUMS_LENGTH
                )
            }

        })
        setOnClickListenerNoAuth(binding?.llLimit2!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_LIMIT_STATISTICS_COUNT_LENGTH
                )
            }

        })
        setOnClickListener(binding?.llCalLengthDifferenceAll!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_ALL
                )
            }

        })
        setOnClickListener(binding?.llCalLengthDifferencePre15!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_PRE15
                )
            }

        })
        setOnClickListener(binding?.llCalLengthDifferenceLimitAnalaysis!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_LIMIT_ANALAYSIS
                )
            }

        })
        setOnClickListener(binding?.llCalLengthDifferenceLimitStatistics!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_LENGTH_DIFFERENCE_LIMIT_STATISTICS
                )
            }

        })
        setOnClickListener(binding?.llCalEndLength!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_CAL_END_LENGTH
                )
            }

        })
        setOnClickListener(binding?.llBetterTrendsPercent!!, object : OnCommonClickListener {
            override fun callback() {
                toClass(
                    SettingCommonEditActivity::class.java,
                    false,
                    Extras.params,
                    MyConstant.TYPE_EDIT_BETTER_TRENDS_PERCENT
                )
            }

        })
        binding?.rgLimitLength!!.setOnCheckedChangeListener { _: RadioGroup?, checkedId: Int ->
            if (!isAllow) {
                return@setOnCheckedChangeListener
            }
            when (checkedId) {
                binding?.rBtnLimitAll?.id -> AppCacheUtil.setLimitType(MyConstant.SWITCH_ALL)
                binding?.rBtnLimit1?.id -> AppCacheUtil.setLimitType(MyConstant.SWITCH_LIMIT1)
                binding?.rBtnLimit2?.id -> AppCacheUtil.setLimitType(MyConstant.SWITCH_LIMIT2)
            }
            postEvent(EventRefreshCalResultType(null))
        }
        binding?.rgCalInterval!!.setOnCheckedChangeListener { group: RadioGroup?, checkedId: Int ->
            if (!isAllow) {
                return@setOnCheckedChangeListener
            }
            when (checkedId) {
                binding?.rBtnCalInterval1?.id -> AppCacheUtil.setCalIntervalNum(1)
                binding?.rBtnCalInterval2?.id -> AppCacheUtil.setCalIntervalNum(2)
                binding?.rBtnCalInterval3?.id -> AppCacheUtil.setCalIntervalNum(3)
            }
            postEvent(EventRefreshCalResultType(null))
        }
        setOnCheckedChangeListenerNoAuth(
            binding?.switchBettingCalArea,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setShowBettingCalArea(true)
                        showMsg("投注计算区已显示")
                    } else {
                        AppCacheUtil.setShowBettingCalArea(false)
                        showMsg("投注计算区已隐藏")
                    }
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchColdAndHotDefault!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setColdAndHotDefault(true)
                        showMsg("冷热号（面板）已显示")
                    } else {
                        AppCacheUtil.setColdAndHotDefault(false)
                        showMsg("冷热号（面板）已隐藏")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchColdAndHotCustom!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setColdAndHotCustom(true)
                        showMsg("冷热号（区域）已显示")
                    } else {
                        AppCacheUtil.setColdAndHotCustom(false)
                        showMsg("冷热号（区域）已隐藏")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchHotShowModelDetail!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setHotShowModelDetail(true)
                        showMsg("热号详细模式已启用")
                    } else {
                        AppCacheUtil.setHotShowModelDetail(false)
                        showMsg("热号详细模式已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListener(
            binding?.switchBetterTrendsPercent!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setUseBetterTrendsPercent(true)
                        showMsg("比重择优已启用")
                    } else {
                        AppCacheUtil.setUseBetterTrendsPercent(false)
                        showMsg("比重择优已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListener(
            binding?.switchTypePercent!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setUseTypePercent(true)
                        showMsg("分类百分比已启用")
                    } else {
                        AppCacheUtil.setUseTypePercent(false)
                        showMsg("分类百分比已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchHandleInput,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        if (!AppCacheUtil.isShowBettingCalArea()) {
                            showMsg("投注计算区显示已关闭，请先开启")
                            binding?.switchHandleInput?.isChecked = false
                        } else {
                            AppCacheUtil.setHandleInputBetting(true)
                            showMsg("手输下注方式已启用")
                        }
                    } else {
                        AppCacheUtil.setHandleInputBetting(false)
                        showMsg("手输下注方式已禁用")
                    }
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchTypeStatisticsCount!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setStatisticsCount(true)
                        showMsg("各类型走势数量统计已启用")
                    } else {
                        AppCacheUtil.setStatisticsCount(false)
                        showMsg("各类型走势数量统计已禁用")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListener(
            binding?.switchCommonAnalysis!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setCommonAnalysis(true)
                        showMsg("通用走势分析已启用")
                        postEvent(EventRefreshCalResultType(null))
                    } else {
                        if (!binding?.switchJumpSmoothly!!.isChecked) {
                            binding?.switchCommonAnalysis!!.isChecked = true
                            showMsg("通用走势与自定义走势至少存在一种")
                        } else {
                            AppCacheUtil.setCommonAnalysis(false)
                            showMsg("通用走势分析已禁用")
                            postEvent(EventRefreshCalResultType(null))
                        }

                    }
                }

            })
        setOnCheckedChangeListener(
            binding?.switchCombinationAnalysis!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setCombinationAnalysis(true)
                        showMsg("组合分析已启用")
                        postEvent(EventRefreshCalResultType(null))
                    } else {
                        AppCacheUtil.setCombinationAnalysis(false)
                        showMsg("组合分析已禁用")
                        postEvent(EventRefreshCalResultType(null))
                    }
                }

            })
        setOnCheckedChangeListener(
            binding?.switchJumpSmoothly!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setJumpSmoothly(true)
                        showMsg("自定义走势分析已启用")
                        setCustomJumpSmoothly(true)
                        postEvent(EventRefreshCalResultType(null))
                    } else {
                        if (!binding?.switchCommonAnalysis!!.isChecked) {
                            binding?.switchJumpSmoothly!!.isChecked = true
                            showMsg("通用走势与自定义走势至少存在一种")
                        } else {
                            AppCacheUtil.setJumpSmoothly(false)
                            showMsg("自定义走势分析已禁用")
                            setCustomJumpSmoothly(false)
                            postEvent(EventRefreshCalResultType(null))
                        }

                    }
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchMax!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setStatisticsCountMax(true)
                        showMsg("各类型走势Max统计已启用")
                    } else {
                        AppCacheUtil.setStatisticsCountMax(false)
                        showMsg("各类型走势Max统计已禁用")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchAnalysisQuick!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setAnalysisQuick(true)
                        showMsg("快捷开关已启用")
                    } else {
                        AppCacheUtil.setAnalysisQuick(false)
                        showMsg("快捷开关已关闭")
                    }
                }

            })
        setOnCheckedChangeListener(
            binding?.switchTrendsAutoFilter!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setTrendsAutoFilter(true)
                        showMsg("自定义走势智能展示已启用")
                    } else {
                        AppCacheUtil.setTrendsAutoFilter(false)
                        showMsg("自定义走势智能展示已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListener(
            binding?.switchCommonSuggest!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setCommonSuggest(true)
                        showMsg("通用走势建议类型已启用")
                    } else {
                        AppCacheUtil.setCommonSuggest(false)
                        showMsg("通用走势建议类型已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListenerNoAuth(
            binding?.switchBettingImitate!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setShowBettingImitate(true)
                        showMsg("单压模拟投注入口已启用")
                    } else {
                        AppCacheUtil.setShowBettingImitate(false)
                        showMsg("单压模拟投注入口已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        setOnCheckedChangeListener(
            binding?.switchNumsScreenOutPre!!,
            object : OnCommonCheckedListener {
                override fun callback(isChecked: Boolean) {
                    if (isChecked) {
                        AppCacheUtil.setNumsScreenOutPre(true)
                        showMsg("筛除前" + AppCacheUtil.getAnalysisNumsScreenOutPreCustom() + "位统计已启用")
                    } else {
                        AppCacheUtil.setNumsScreenOutPre(false)
                        showMsg("筛除前" + AppCacheUtil.getAnalysisNumsScreenOutPreCustom() + "位统计已关闭")
                    }
                    postEvent(EventRefreshCalResultType(null))
                }

            })
        binding?.rgAnalaysisModel!!.setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener { _, checkedId ->
            if (!isAllow) {
                return@OnCheckedChangeListener
            }
            if (checkedId == binding?.rBtnAnalaysisModel1?.id) {
                AppCacheUtil.setAnalaysisModel2(false)
                showMsg("分析模式1已启用")
            } else {
                AppCacheUtil.setAnalaysisModel2(true)
                showMsg("分析模式2已启用")
            }
            postEvent(EventRefreshCalResultType(null))
        })
    }

    private fun setCustomJumpSmoothly(isOpen: Boolean) {
        for (itemBean in mSuggestItemBeanList) {
            itemBean.isEnable = isOpen
            AppCacheUtil.setTrendActive(itemBean.tag, isOpen)
        }
        mAdapter!!.addAllData(mSuggestItemBeanList)
    }
}